//
//  SettingVCRegularButton.m
//  liBaQiang
//
//  Created by 奇林刘 on 2018/11/12.
//  Copyright © 2018年 liu. All rights reserved.
//

#import "SettingVCRegularButton.h"

@interface SettingVCRegularButton ()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIImageView *rightImageView;

@end

@implementation SettingVCRegularButton {
    NSString *_name;
    void(^_event)(void);
}

- (instancetype)initWithName:(NSString *)name event:(void(^)(void))event {
    _name = name.copy;
    _event = event;
    self = [super init];
    return self;
}

- (void)configSelf {
    self.fp_backgroundColor(HexadecimalColor(@"#FFFFFF"));
    [self addTarget:self action:@selector(onSelfTap) forControlEvents:UIControlEventTouchUpInside];
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(RPX(375)));
        make.height.equalTo(@(RPX(49)));
    }];
}

- (void)allocateComponents {
    self.fp_addSubview(self.nameLabel = [[UILabel alloc] init]);
    self.fp_addSubview(self.rightImageView = [[UIImageView alloc] init]);
}

- (void)layoutComponents {
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(RPX(15));
    }];
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(RPX(-15));
        make.width.equalTo(@(RPX(7)));
        make.height.equalTo(@(RPX(13)));
    }];
}

- (void)configComponents {
    self.nameLabel.fp_font(RPXFont(16)).fp_text(_name);
    [self.rightImageView setImage:[UIImage imageNamed:@"right"]];
}

- (void)onSelfTap {
    _event();
}

@end
